Repository navigation
fix(runtime): bound pytest deadlocks and Antigravity Stop-hook trajectory scan - #9015
loopx-agent wants to merge 1 commit into
Conversation
…tory scan Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google (self_reported)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
已针对 PR #9015 exact head efdc510330fc04ea0de0a26558c4b07e3c98bd36 完成完整静态检验、反事实/边界单测实证与 premerge 金丝雀检查(审查结论:APPROVE,无 P0/P1/P2 阻塞问题;[VERDICT: APPROVE])。
动机 / Motivation
受影响调用方与运维者:所有在本地、Subagent 或 CI 通道运行 pytest 测试套件的开发者与自动化巡检 Agent,以及所有配置 hooks.json Stop 钩子以在网络 EOF 断流后原地恢复长程常驻会话的 Antigravity App(antigravity_app)运行方。
修改前(7bc56e7468):pyproject.toml [tool.pytest.ini_options] 未设置 faulthandler_timeout 与 faulthandler_exit_on_timeout,一旦某个测试用例发生死锁或阻塞,整个测试进程会在超过 CI 120s --ci-stall-after 诊断后仍无限期挂起(本轮 Subagent 挂起超 5 小时直至服务端重启);同时 loopx/agy_goal_mode/host_runtime.py 中 _native_input 对 GetCascadeTrajectorySteps 请求 [0, total) 全量步骤(timeout=2s)并含 3 处 Any,在长程常驻会话(步数数千至上万步)下易因超时或单页截断导致 stop_hook 静默返回 {} 无法恢复 EOF 断流。修改后(efdc510330):pyproject.toml 增加 faulthandler_timeout = 180(高于 CI 120s 协作栈快照阈值)与 faulthandler_exit_on_timeout = true 保证死锁测试在 180s 后打印全线程栈并退出;host_runtime.py 改为按 _TRAJECTORY_TAIL_WINDOW = 200 从 total 向前有界窗口扫描(总预算 _TRAJECTORY_SCAN_DEADLINE_SECONDS = 8.0,兼容旧服务端未分页全量返回)并清零全部 Any 注解(lines=280, any_count=0),保持 anchor SHA-256 与前后一致性校验完全不变。
可观测结果:exact head efdc510330 上:module_metrics 验证 loopx/agy_goal_mode/host_runtime.py (lines=280, any_count=0, dict_any_count=0);uv run --extra test mypy --strict --follow-imports=silent loopx/agy_goal_mode/host_runtime.py 与全仓 17 文件 mypy 均 0 错;ruff check 在全部修改 Python 文件上通过;8 组套件(test_antigravity_host_runtime.py、test_agy_host_surface.py、test_python_ci_workflow.py、test_ci_pytest_timing.py、test_stage2c_dependency_lock.py、test_dependency_security_boundaries.py、test_maintainability_ratchet.py、test_semantic_vocabulary_drift.py)通过:795 passed in 63.30s(0 failed, 0 skipped),其中两项新增单测实证死锁测试在超时后非零退出且长轨 5000 步下仅请求尾部 <=200 步窗口;uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base 7bc56e74687a93ff4d5bcccb532c454bf2379c29 返回 ok=true, gate.status="passed"(direct=6/6, selected=3/3, failures=0, manual_holds=0);loopx check --scan-path ... 返回 ok=true(errors=0, warnings=0)。
非目标边界:本 PR 不改动 CI --ci-stall-after 120 观察器或 scripts/ci/pytest_timing.py 逻辑,不改变 Stop 钩子的重试次数上限(2 次)或 anchor SHA-256 生成公式,亦不修改与开放 PR #8703(module_metric_baseline.json 打包规则)或 PR #8874(bootstrap_prompt 文案与 __init__.py 模板)重迭的区域。
改动思路 / Approach
死锁兜底配置直接归属仓级 [tool.pytest.ini_options],Antigravity Stop 钩子轨迹扫描直接收敛在 loopx/agy_goal_mode/host_runtime.py 原所有者内部,复用 antigravity_adapter._observed_turn_steps 现有步序号校验契约而未引入新抽象或状态文件。
当前 PR 边界:仅包含 pyproject.toml(+3/-0)、loopx/agy_goal_mode/host_runtime.py(+57/-26)、tests/test_antigravity_host_runtime.py(+71/-0)与 tests/test_python_ci_workflow.py(+34/-0)四处高内聚改动(总计 +165/-26)。
pyproject.toml有界死锁退出(faulthandler_timeout = 180、faulthandler_exit_on_timeout = true):设置在 CI--ci-stall-after 120(120s 先打印合作式栈快照)之上,仅拦截真正超过 3 分钟卡死的单测,使其输出全部线程堆栈并失败退出。host_runtime._native_input向后尾部窗口分页 + 零Any:从total起按 200 步窗口逆向读取GetCascadeTrajectorySteps,在_TRAJECTORY_SCAN_DEADLINE_SECONDS = 8.0预算内找到最近一次CORTEX_STEP_TYPE_USER_INPUT即停止,同时保留start > 0 and len(raw) == total时对旧版未分页服务端的一次性全量兼容及调用前后GetCascadeTrajectory一致性核验。
具体改动 / Changes
本次 diff 严格限定在 4 个文件(+165 / -26):
pyproject.toml(+3 / -0,L204-206):在[tool.pytest.ini_options]下新增faulthandler_timeout = 180与faulthandler_exit_on_timeout = true,确保本地及 subagent 的pytest进程不会因单个死锁测试而无限挂起。loopx/agy_goal_mode/host_runtime.py(+57 / -26,280行,0 Any/0 dict[str, Any]):新增_TRAJECTORY_TAIL_WINDOW = 200与_TRAJECTORY_SCAN_DEADLINE_SECONDS = 8.0将_native_input改为向后有界窗口扫描,并移除全文件 3 处Any改用严格Mapping/object类型窄化。tests/test_python_ci_workflow.py(+34 / -0):新增test_pytest_config_enforces_bounded_deadlock_exit_above_ci_stall_snapshot校验配置阈值并在真实子进程用死锁用例验证非零超时退出与Timeout堆栈输出。tests/test_antigravity_host_runtime.py(+71 / -0):新增test_native_input_reads_bounded_tail_windows_on_long_trajectories验证 5000 步轨迹单窗命中、多窗回溯及全无输入返回None三条路径。
对主干的风险 / Risks
- 阈值与兼容性:
faulthandler_timeout = 180仅作用于单个卡死超过 3 分钟的测试(CI 分片现有--ci-stall-after 120在前),正常慢测试与测试套件总耗时不受影响;_native_input在旧版忽略分片范围的服务端返回全量len(raw) == total时自动一次收敛退出,不破坏既有测试双端行为。 - 并行 PR 避让:
pyproject.toml改动[tool.pytest.ini_options],host_runtime.py改动_native_input/类型注解,test_antigravity_host_runtime.py追加于文件末尾,均与在途 #8703 / #8874 行段隔离。 - 合入前提:涉及仓级测试超时策略与核心运行时钩子,需维护者合并授权与远端 CI 完成检查。
我的整体评价 / Verdict
- Long-horizon 影响:
improved— 根除本地/Subagent 测试死锁无限挂起风险,并修复长程 Antigravity 会话达到数千步后Stop钩子全量拉取轨迹超时失灵问题。 - User-experience 影响:
improved— 常驻长会话在模型 stream EOF 断流时可持续稳定触发原地恢复,且测试卡死可在 180s 内带堆栈快速暴露。 - visual_review:
not_applicable— 测试配置与运行时恢复后端,无前端/UI 表面。
定位精准、边界清晰、验证充实;待维护者合并授权与远端 CI 通过后可安全合入。
[VERDICT: APPROVE]
English verdict: APPROVE exact head efdc510 (author-owned COMMENTED approval review); bounds deadlocked pytest runs via faulthandler_timeout=180 / faulthandler_exit_on_timeout=true in pyproject.toml above CI's 120s stall observer, replaces unbounded [0, total) trajectory fetches in loopx/agy_goal_mode/host_runtime.py:_native_input with 200-step backward tail windows and eliminates all Any usages (280 lines, 0 Any), verified by 795 passed pytest tests (incl. two new deadlock/long-trajectory regression tests), strict mypy (0 issues), ruff check, quick premerge canaries (0 failures), and loopx check clean.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
本地和 CI 开发者需要从卡住的 pytest 进程退出,常驻 Antigravity 会话需要在 EOF 后按原输入恢复。 旧入口一次读取全轨迹,测试进程没有跨用例的 faulthandler 硬退出配置。 用 1000 步轨迹、每页 1.55 秒、元数据 RPC 1.8 秒、准入应答 8 秒重放同一 Stop 事件。旧头 19.1 秒返回 continue。候选按生成配置的 30 秒在外层超时,stdout 和重试记录均为空。放宽测试容器计时后,候选 31.3 秒才返回 continue。 新头为 pytest 设置有界诊断和退出,并把 Stop 的轨迹查询改为每页 200 步。 评审限于本地测试与 Stop 回调的有界行为。实际 App 及模型的长期效果另验。
改动思路 / Approach
pytest faulthandler 配置保留在 pyproject。Stop 的查询仍由原 Antigravity Host adapter 负责。 两条路径各有自己的入口和时限。Stop 应按一次完整请求核算,而测试硬退出应用明确的仓级默认。 保留读取前后校验和 Core 现有准入。通过真实 stdio 子进程,在 30 秒外层边界和较长对照中分别观察。
具体改动 / Changes
逐项检查当前头 efdc510 和 merge base 7bc56e7,4 个文件,+165/-26。AGY-STOP-TIMEBOX 的整条回调仍可能超时。PYTEST-STALL-EXIT 的受控子进程通过。范围包括两个生产配置入口及各自测试。维护原 anchor 组成和现有的两次重试上限。 评审依据为 7bc56e7。 目标规范
关键代码讲解
对主干的风险 / Risks
[P2] 两次分页和准入超过已配置的 Stop 回调时限。 用 1000 步轨迹、每页 1.55 秒、元数据 RPC 1.8 秒、准入应答 8 秒重放同一 Stop 事件。旧头 19.1 秒返回 continue。候选按生成配置的 30 秒在外层超时,stdout 和重试记录均为空。放宽测试容器计时后,候选 31.3 秒才返回 continue。 给一次 Stop 使用同一个截止时间,给 Core 准入和重验预留时间,并让每个 RPC 只使用实际剩余预算。用生成配置的 30 秒验证整条入口,检查继续或及时返回空 JSON,并核对重试记录。 单个 RPC 和准入均在自己的超时内,这个组合仍会吞掉原生 EOF 恢复。
本地 HTTP 快速对照完成两次多页扫描并保留原输入,成功返回 continue 且只写一条重试记录。取消、配额拒绝及输入改变仍在已有拒绝路径。真实 pytest 子进程的缩短超时夹具通过。 当前提交定向 795 项通过。Ruff 和源码模块严格 mypy 通过,quick premerge 的六项直接及三项所选检查通过。 使用源检出、真实 stdio 和 loopback HTTP,故障与耗时来自合成服务及准入夹具。Antigravity App 实装、实际语言服务器负载和远端 CI 未验证。
我的整体评价 / Verdict
请求修改。pytest faulthandler 配置保留在 pyproject。Stop 的查询仍由原 Antigravity Host adapter 负责。 两条路径各有自己的入口和时限。Stop 应按一次完整请求核算,而测试硬退出应用明确的仓级默认。 在真实 Host 的时限内交付本次回调结果仍有缺口。 保留已验证的 pytest 硬退出与快速回调路径,再补齐完整请求的超时对照。 没有新可视界面,实际检验原生 stdio 回调和测试配置。 使用源检出、真实 stdio 和 loopback HTTP,故障与耗时来自合成服务及准入夹具。Antigravity App 实装、实际语言服务器负载和远端 CI 未验证。
English verdict: REQUEST_CHANGES at efdc510. The 19.1s baseline returns continue under the generated 30s limit; the candidate times out without a response or reservation and returns only after 31.3s with a larger harness timeout. The pytest timeout control passes.
| timeout=2, | ||
| ).get("steps") | ||
| if not isinstance(raw, list) or len(raw) != total: | ||
| deadline = time.monotonic() + _TRAJECTORY_SCAN_DEADLINE_SECONDS |
There was a problem hiding this comment.
[P2] 两次分页和准入超过已配置的 Stop 回调时限。用 1000 步轨迹、每页 1.55 秒、元数据 RPC 1.8 秒、准入应答 8 秒重放同一 Stop 事件。旧头 19.1 秒返回 continue。候选按生成配置的 30 秒在外层超时,stdout 和重试记录均为空。放宽测试容器计时后,候选 31.3 秒才返回 continue。 给一次 Stop 使用同一个截止时间,给 Core 准入和重验预留时间,并让每个 RPC 只使用实际剩余预算。用生成配置的 30 秒验证整条入口,检查继续或及时返回空 JSON,并核对重试记录。
Summary
Fix two systemic hang/timeout failure modes discovered when subagents ran broad
pytestsweeps and long-horizon resident Antigravity sessions hit EOF recovery:pytestruns (pyproject.toml): configurefaulthandler_timeout = 180andfaulthandler_exit_on_timeout = trueunder[tool.pytest.ini_options], set cleanly above CI's--ci-stall-after 120cooperative diagnostic snapshot so hung tests dump all thread tracebacks and exit after 180s instead of freezing local/subagent/CI processes indefinitely.Stophook trajectory scans + eliminateAny(loopx/agy_goal_mode/host_runtime.py): replace unboundedGetCascadeTrajectorySteps(startIndex=0, endIndex=total)full-history fetches in_native_inputwith backward 200-step tail-window pagination (_TRAJECTORY_TAIL_WINDOW = 200,_TRAJECTORY_SCAN_DEADLINE_SECONDS = 8.0) plus legacy unpaginated server fallback, preventing RPC timeouts/truncation on long-horizon resident sessions while keeping the step anchor hash and consistency checks identical; also replace allAnyannotations with strictMapping/objecttypes (0Any).tests/test_python_ci_workflow.py::test_pytest_config_enforces_bounded_deadlock_exit_above_ci_stall_snapshottests/test_antigravity_host_runtime.py::test_native_input_reads_bounded_tail_windows_on_long_trajectoriesVerification
loopx/agy_goal_mode/host_runtime.pylines=280 any_count=0 dict_any_count=0uv run --extra test mypy --strict --follow-imports=silent loopx/agy_goal_mode/host_runtime.py:0issuesuv run --extra test mypy(17 kernel files):0issuesuv run --extra test ruff check loopx/agy_goal_mode/host_runtime.py tests/test_antigravity_host_runtime.py tests/test_python_ci_workflow.py: passedtest_antigravity_host_runtime.py,test_agy_host_surface.py,test_python_ci_workflow.py,test_ci_pytest_timing.py,test_stage2c_dependency_lock.py,test_dependency_security_boundaries.py,test_maintainability_ratchet.py,test_semantic_vocabulary_drift.py):795 passed in 63.30s(0failed,0skipped)uv run --extra test loopx --format json canary premerge --tier quick --from-git-diff --git-diff-base 7bc56e74687a93ff4d5bcccb532c454bf2379c29:ok: true,gate.status: "passed",failures: [](6direct checks,3catalog canaries)uv run --extra test loopx check --scan-path ...:ok: true,errors: 0,warnings: 0(public boundary scan clean)